<!-- 安全培训资料 -->
<template>
	<view>
		<view v-if="show">
			<web-view :update-title="false" :src="pdfUrl" :fullscreen="false" :webview-styles="webviewStyle"></web-view>
		</view>
		<u-empty></u-empty>
		<view class="bt-footer" v-if="show">
			<bg-btn @click="back()">我已学习</bg-btn>
		</view>
	</view>
</template>

<script>
	import { getFile } from "../../../api/system/dict"
	import {trainingDetail, trainingOver} from "@/api/system/study.js"
	export default {
		onLoad(options){
			this.projectId = options.projectId
		},
		data() {
			return {
				show:true,
				projectId:'',
				obj:{},
				fileUrl:'',
				pdfUrl:'',
				webviewStyle:{
					height:"620px"
				}
			}
		},
		mounted() {
			this.getDetail()
		},
		methods: {
			getDetail(){
				trainingDetail(this.projectId).then(res=>{
					this.obj = res.data
					if(this.obj.safetyFileUrl){
						this.show = true
						this.pdfUrl = '/hybrid/html/web/viewer.html?file='+encodeURIComponent(this.obj.safetyFileUrl)
						// getFile(this.obj.safetyFileUrl).then(res=>{
						// 	this.fileUrl = res.data
							
						// })
					} else {
						this.show = false
					}
					
				})
			},
			back(){
				trainingOver({trainingId:this.obj.id}).then(res=>{
					uni.navigateBack()
				})
			}
		}
	}
</script>

<style>

</style>
